<template lang="pug">
    skin(@up="up",@down="down",@yes="yes",@back="back",@duringUp="up",@duringDown="down")
        div(class="flex-column h3")
            div(class="flex-column-item") 
              div(class="flex-row")
                div(div class="flex-row-item  flex-center-center flex-7") ----菜单设置-----
                div(div class="flex-row-item right") {{activeId + 1}}
            div(class="flex-column-item flex-center flex-3") 
              div(class="flex-row")
                  div(class="flex-row-item flex-7",style="height:100%")
                      div(class="flex-column")
                        div(class="flex-column-item",v-for="(menu,index) in currentPageMenus")
                          div(class="flex-row")
                            div(class="flex-row-item flex-4") 
                              span(class="iconfont",:style="{'visibility': index == currentMenuIndex ? 'visible' : 'hidden'}") &#xe62c;
                              span {{menu.name}}
                            div(class="flex-row-ietm center flex-1") 
                              control-select(v-model="currentPageMenus[index]", :ref="'ref' + menu.id", :working="menu.working",v-if="!menu.isControlAmount")
                              control-amount(v-model="currentPageMenus[index]", :ref="'ref' + menu.id", :working="menu.working",v-else)
                              span {{menu.unit}}

                  div(class="flex-row-item right",style="height:100%")
                    control-line(:total="menus.length",:current="activeId",style="float:right;")
</template>

<script>
    import MenuList from '@/mixins/MenuList'
    export default {
        mixins:[MenuList],
        data() {
            return {
                menus: [
                    {
                        name: "方波大剂量",
                        value: window.MenuSwitch.rectSquare,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        working: false,
                        id: 1,
                        onChange(model) {
                            window.MenuSwitch.rectSquare = model.value;
                        }
                    },
                    {
                        name: "三餐量预设",
                        value: window.MenuSwitch.threeMeals,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        working: false,
                        id: 2,
                        onChange(model) {
                            window.MenuSwitch.threeMeals = model.value;
                        }
                    },
                    {
                        name: "大剂量向导",
                        value: window.MenuSwitch.largeDoseWirzard,
                        working: false,
                        id: 3,options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                           window.MenuSwitch.largeDoseWirzard = model.value;
                        }
                    },
                    {
                        name: "基础率快设",
                        value: window.MenuSwitch.baseRateFastSetting,
                        working: false,
                        id: 0,options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                           window.MenuSwitch.baseRateFastSetting = model.value;
                        }
                    },
                    {
                        name: "临基率设置",
                        value: window.MenuSwitch.baseRateTempSetting,
                        working: false,
                        id: 4,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                            window.MenuSwitch.baseRateTempSetting = model.value;
                        }
                    }
                    ,
                    {
                        name: "基础率方案",
                        value: window.MenuSwitch.baseRatePlan,
                        working: false,
                        id: 5,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                            window.MenuSwitch.baseRatePlan = model.value;
                        }
                    },
                    {
                        name: "校正基础率",
                        value: window.MenuSwitch.baseRateCorrection,
                        working: false,
                        id: 6,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                            window.MenuSwitch.baseRateCorrection = model.value;
                        }
                    },
                    {
                        name: "闹铃设置",
                        value: window.MenuSwitch.ringSetting,
                        working: false,
                        id: 7,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                            window.MenuSwitch.ringSetting = model.value;
                        }
                    },
                    {
                        name: "警示设置",
                        value: window.MenuSwitch.warningSetting,
                        working: false,
                        id: 8,
                        options: [{name: "关", value: false}, {name: "开", value: true}],
                        onChange(model) {
                            window.MenuSwitch.warningSetting = model.value;
                        }
                    }
                ]
            };
        },
        computed:{
            currentMenuRef(){
                return "ref" + this.currentMenu.id
            },
        },
        methods: {
            up() {
                if (this.currentMenu.working) {
                    this.$refs[this.currentMenuRef][0].up();
                    return;
                }

                this.activeId--;
            },
            down() {
                if (this.currentMenu.working) {
                    this.$refs[this.currentMenuRef][0].down();
                    return;
                }

                this.activeId ++;
            },

            back() {
                if (this.currentMenu.working) {
                    this.currentMenu.working = false;
                } else {
                    this.$router.push("/advance-setting/doctor1");
                }
            },
            yes() {
                this.currentMenu.working = !this.currentMenu.working;
            }
        },
        created() {
            // this.currentItem = this.items[0];
        }
    };
</script>

<style lang="less">
</style>
